<?php
/**
 * Created by PhpStorm.
 * User: jimmyhsu
 * Date: 2016/9/28
 * Time: 下午5:24
 */
include ("conn.php");//连接数据库
$username=str_replace(" ","",$_POST['name']);//接收客户端发来的username；
$sql="select * from userinfo where name='$username'";

$query=mysql_query($sql);
$rs = mysql_fetch_array($query);
if(md5($_POST['pwd'])==$rs['password']){
    // if ($_POST['deviceId'] == $rs['deviceid']) {
	$deviceId = $_POST['deviceId'];
	$sql = "update userinfo set deviceid = '$deviceId' where userinfo.name = '$username'";
	mysql_query($sql);
		echo "login succeed";

    // }else{
    //     echo "need verify:".$rs['mobile'];
    // }
}else{
    echo "error"; 
}